package com.passengerflowmanagementsystem.statistics.service.impl;

import java.util.List;
import com.passengerflowmanagementsystem.common.utils.DateUtils;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionHall;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionShop;
import com.passengerflowmanagementsystem.statistics.mapper.EmExhibitionHallMapper;
import com.passengerflowmanagementsystem.statistics.mapper.EmExhibitionShopMapper;
import com.passengerflowmanagementsystem.statistics.domain.EmExhibitionCabinet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.passengerflowmanagementsystem.statistics.mapper.EmExhibitionCabinetMapper;
import com.passengerflowmanagementsystem.statistics.service.IEmExhibitionCabinetService;

/**
 * 展柜Service业务层处理
 * 
 * @author sheng
 * @date 2024-10-28
 */
@Service
public class EmExhibitionCabinetServiceImpl implements IEmExhibitionCabinetService 
{
    @Autowired
    private EmExhibitionCabinetMapper emExhibitionCabinetMapper;

    @Autowired
    private EmExhibitionShopMapper emExhibitionShopMapper;

    @Autowired
    private EmExhibitionHallMapper emExhibitionHallMapper;

    /**
     * 查询
     * 
     * @param cabinetId
     * @return
     */
    @Override
    public EmExhibitionCabinet selectEmExhibitionCabinetByCabinetId(Long cabinetId)
    {
        return emExhibitionCabinetMapper.selectEmExhibitionCabinetByCabinetId(cabinetId);
    }

    /**
     * 查询
     * 
     * @param emExhibitionCabinet
     * @return
     */
    @Override
    public List<EmExhibitionCabinet> selectEmExhibitionCabinetList(EmExhibitionCabinet emExhibitionCabinet)
    {
        List<EmExhibitionCabinet> cabinetList = emExhibitionCabinetMapper.selectEmExhibitionCabinetList(emExhibitionCabinet);
        if (cabinetList.size() > 0){
            for (EmExhibitionCabinet cabinet : cabinetList){
                if (cabinet.getShopId() != null) {
                    EmExhibitionShop shop = emExhibitionShopMapper.selectEmExhibitionShopByShopId(cabinet.getShopId());
                    cabinet.setShopName(shop.getShopName());
                }
                if (cabinet.getHallId() != null){
                    EmExhibitionHall hall = emExhibitionHallMapper.selectEmExhibitionHallByHallId(cabinet.getHallId());
                    cabinet.setHallName(hall.getHallName());
                }
            }
        }
        return cabinetList;
    }

    /**
     * 新增
     * 
     * @param emExhibitionCabinet
     * @return
     */
    @Override
    public int insertEmExhibitionCabinet(EmExhibitionCabinet emExhibitionCabinet)
    {
        emExhibitionCabinet.setCreateTime(DateUtils.getNowDate());
        return emExhibitionCabinetMapper.insertEmExhibitionCabinet(emExhibitionCabinet);
    }

    /**
     * 修改
     * 
     * @param emExhibitionCabinet
     * @return
     */
    @Override
    public int updateEmExhibitionCabinet(EmExhibitionCabinet emExhibitionCabinet)
    {
        emExhibitionCabinet.setUpdateTime(DateUtils.getNowDate());
        return emExhibitionCabinetMapper.updateEmExhibitionCabinet(emExhibitionCabinet);
    }

    /**
     * 批量删除
     * 
     * @param cabinetIds
     * @return
     */
    @Override
    public int deleteEmExhibitionCabinetByCabinetIds(Long[] cabinetIds)
    {
        return emExhibitionCabinetMapper.deleteEmExhibitionCabinetByCabinetIds(cabinetIds);
    }

    /**
     * 删除
     * 
     * @param cabinetId
     * @return
     */
    @Override
    public int deleteEmExhibitionCabinetByCabinetId(Long cabinetId)
    {
        return emExhibitionCabinetMapper.deleteEmExhibitionCabinetByCabinetId(cabinetId);
    }
}
